package uk.ac.glasgow.demosocs.impl.ui;

import uk.ac.glasgow.clui.SystemCommand;
import uk.ac.glasgow.clui.SystemCommandException;
import uk.ac.glasgow.demosocs.VotingSystem;

public class ManCommand extends SystemCommand<VotingSystem> {

	enum Choice {
		create, user, election, edit, elections, nominate, accept, nominations, cast, publish
	};

	public ManCommand(VotingSystem facade) {
		super(facade);
	}

	@Override
	public String processCommand(String[] arguments)
			throws SystemCommandException {

		/*
		 * deals with the case of there being no arguments (stops program from
		 * exiting)
		 */
		if (arguments.length == 0) {
			return "Correct usage: man/m <command>\n";
		}

		String myChoice = arguments[0];
		Choice ch = null;
		
		try{
			ch = Choice.valueOf(myChoice);
		
		if (Choice.valueOf(myChoice) != null) {

			switch (ch) {
			case create:
				System.out
						.println("Create a new election with the specified parameters.");
				break;
			case user:
				System.out.println("Sets the currently selected user.");
				break;
			case election:
				System.out.println("Sets the currently selected election.");
				break;
			case edit:
				System.out
						.println("Edit the currently selected election details.");
				break;
			case elections:
				System.out.println("List all elections.");
				break;
			case nominate:
				System.out
						.println("Nominate the specified candidate in the current election.");
				break;
			case accept:
				System.out
						.println("Accept a nomination for the currently selected election.");
				break;
			case nominations:
				System.out
						.println("List all nominations for the currently selected user.");
				break;
			case cast:
				System.out
						.println("Cast a vote in the currently selected election for the specified candidate.");
				break;
			case publish:
				System.out
						.println("Publish the results of the currently selected election.");
				break;
			default:
				System.out.println("Command not recognised, please try again");
				break;
			}
		} else
			System.out.println("No usage provided");
		return "\n";
		}
		catch(IllegalArgumentException e){
			System.out.println("Command does not exist, please try again");
			return "\n";
		}
	}
}
